<template>
  <div style="width: 100%; height: 100%" v-loading="loading">
    <CustomLink :url="url"/>
  </div>
</template>
<script setup>
import {onMounted, shallowRef} from 'vue';
import {useRoute} from 'vue-router';
import {getAction} from '@/request/BaseRequest';
import {isNotEmpty} from '@/utils/CommonUtils';
import CustomLink from '@/components/CustomLink';

const route = useRoute();
onMounted(() => {
  loadMenu(route.query.menuId);
});
const loading = shallowRef(false);
const url = shallowRef();

function loadMenu(menuId) {
  loading.value = true;
  getAction('/platwork/loadMenuById', {menuId}).then(data => {
    loading.value = false;
    if (data.success) {
      let result = data.result;
      console.log(result.appMenu);
      console.log(result.appMenu.url);
      setAppMenuUrl(result);
    }
  });
}

function setAppMenuUrl(result) {
  if (isNotEmpty(result) && isNotEmpty(result.appMenu) && isNotEmpty(result.appMenu.url)) {
    console.log(url);
    url.value = result.appMenu.url;
  }
}
</script>
